package com.yandadeyu.springBoot.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2018/6/8.
 */
@Repository
public interface CustomerRepository extends JpaRepository<Customer, Long> {
    //查询
    List<Customer> findByUserName(String userName);
    Customer findByUserNameOrEmail(String username, String email);

    // 更新用户的名称
    @Modifying // 此次注解说明该sql 是修改数据的sql
    @Query("update customer set  user_name = ?1 where  id = ?2 ")
    int modifyByIdAndUserID(String userName,Long id);

/*
    // 删除用户
    @Transactional // 添加实物的支持
    @Modifying
    @Query("delete from cusotmer where id=?1")
    int deleteUserByUserName(Long id);*/


}
